package com.couldsail.takeaway.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.couldsail.takeaway.mapper.BannerMapper;
import com.couldsail.takeaway.pojo.entity.Banner;
import com.couldsail.takeaway.pojo.vo.BannerVO;
import com.couldsail.takeaway.service.BannerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@RequiredArgsConstructor
@Slf4j
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {
    private final BannerMapper bannerMapper;
    @Override
    public List<BannerVO> getBannerList(String id) {
        QueryWrapper<Banner> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("shop_id",id);
        return bannerMapper.selectList(queryWrapper).stream()
                .map(banner -> {
                    BannerVO bannerVO = new BannerVO();
                    BeanUtils.copyProperties(banner, bannerVO);
                    return bannerVO;
                })
                .toList();
    }
}
